import com.dmotiko.general.*

class MovieLoaderClip
extends BaseClip {
	
	public static var CLIP_LOADED:String = "movieloaderclip_clipLoaded";
	
	private var mcContainer:MovieClip;
	private var mcl:MovieClipLoader;
	
	function MovieLoaderClip(){
		super();
	}
	
	/**
	 * @author: sminutoli
	 * @usage:  deja que se inicialicen primero las variables y luego tira el evento de onLoad
	 */
	private function initClip(){
		mcl = new MovieClipLoader();
		mcl.addListener(this);
	}
	
	public function loadContent(src:String):Void {
		if(!mcContainer) this.createEmptyMovieClip("mcContainer", this.getNextHighestDepth());
		mcl.loadClip(src, mcContainer);
	}
	
	public function onLoadError():Void {
		trace("com.dmotiko.general.MovieLoaderClip onLoadError");
	}
	
	public function onLoadProgress(target, loaded, total) {
		dispatchEvent( { target: this, type: BaseClipEvent.CHANGED, loaded: loaded, total: total } );
	}
	
	public function onLoadInit(){
		dispatchEvent( { target: this, type: CLIP_LOADED, clip: mcContainer } );
	}
}